﻿<dx:DXWindow
    xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:dxb="http://schemas.devexpress.com/winfx/2008/xaml/bars"
    xmlns:dxlc="http://schemas.devexpress.com/winfx/2008/xaml/layoutcontrol"
    xmlns:dxdo="http://schemas.devexpress.com/winfx/2008/xaml/docking"
    xmlns:dxn="http://schemas.devexpress.com/winfx/2008/xaml/navbar"
    xmlns:loki="clr-namespace:Loki.UI.Wpf;assembly=Loki.UI.Wpf"
    x:Class="Luna.UI.Main.MainView"
    Icon="../Resources/icon.png"
    WindowStartupLocation="CenterOwner"
    WindowState="Maximized"
    BorderEffect="Default"
    EnableTransparency="False"
    WindowStyle="ThreeDBorderWindow">
    <dx:DXWindow.Resources>
        <Style TargetType="dxb:BarButtonItem" x:Key="MNI_Style">
            <Setter Property="BarItemDisplayMode" Value="Default" />
            <Style.Triggers>
                <DataTrigger Binding="{Binding Command.Name}" Value="Application.Search">
                    <Setter Property="Glyph" Value="{StaticResource MNI_search}" />
                </DataTrigger>
                <DataTrigger Binding="{Binding Command.Name}" Value="Luna.Geolocalize">
                    <Setter Property="Glyph" Value="{StaticResource MNI_geolocalize}" />
                </DataTrigger>
                <DataTrigger Binding="{Binding Command.Name}" Value="Luna.Dashboard">
                    <Setter Property="Glyph" Value="{StaticResource MNI_dashboard}" />
                </DataTrigger>
                <DataTrigger Binding="{Binding Command.Name}" Value="Application.Add">
                    <Setter Property="Glyph" Value="{StaticResource MNI_add}" />
                </DataTrigger>
                <DataTrigger Binding="{Binding Command.Name}" Value="Application.Refresh">
                    <Setter Property="Glyph" Value="{StaticResource MNI_refresh}" />
                </DataTrigger>
                <DataTrigger Binding="{Binding Command.Name}" Value="Application.Save">
                    <Setter Property="Glyph" Value="{StaticResource MNI_save}" />
                    <Setter Property="KeyGesture" Value="Ctrl+S" />
                </DataTrigger>
            </Style.Triggers>
        </Style>
        <DataTemplate x:Key="mni_template">
            <ContentControl>
                <dxb:BarButtonItem Content="{Binding DisplayName}"
                                   GlyphAlignment="Top"
                                   GlyphSize="Large"
                                   Style="{StaticResource MNI_Style}"
                                   BarItemDisplayMode="Default"
                                   Command="{Binding Command}" />
            </ContentControl>
        </DataTemplate>
        <BooleanToVisibilityConverter  x:Key="CVT_BoolToVisibiliy" />
        <DoubleAnimation x:Key="ShowSearchAnimation" Storyboard.TargetProperty="Width" To="250" Duration="0:0:0.2" />
        <DoubleAnimation x:Key="HideSearchAnimation" Storyboard.TargetProperty="Width" To="0" Duration="0:0:0.2" />
        <Style TargetType="dxn:NavBarGroup">
            <Setter Property="Header" Value="{Binding DisplayName}" />
            <Setter Property="ItemsSource" Value="{Binding Children}" />
        </Style>
        <Style TargetType="dxn:NavBarItem">
            <Setter Property="loki:Bind.Model" Value="{Binding}" />
        </Style>
    </dx:DXWindow.Resources>
    <dxb:BarManager>
        <dxb:BarManager.Items>
            <dxb:BarStaticItem x:Name="StatusFileName" Content="{Binding Configuration.Status.CurrentFile}" Alignment="Near" BarItemDisplayMode="Content" />
        </dxb:BarManager.Items>
        <dxb:BarManager.Bars>
            <dxb:Bar ItemStyle="{StaticResource MNI_Style}" ItemTemplate="{StaticResource mni_template}" Caption="Main Menu" IsMainMenu="True" DataContext="{Binding Menu}" ItemLinksSource="{Binding Items}">
                <dxb:Bar.DockInfo>
                    <dxb:BarDockInfo ContainerType="Right" />
                </dxb:Bar.DockInfo>
            </dxb:Bar>
            <dxb:Bar x:Name="statusBar" Caption="Status Bar" IsStatusBar="True" UseWholeRow="True">
                <dxb:Bar.DockInfo>
                    <dxb:BarDockInfo ContainerType="Bottom" />
                </dxb:Bar.DockInfo>
                <dxb:BarStaticItemLink BarItemName="StatusFileName" />
            </dxb:Bar>
        </dxb:BarManager.Bars>
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="250" />
            </Grid.ColumnDefinitions>
            <Grid.Background>
                <ImageBrush ImageSource="{StaticResource BACK}" Stretch="UniformToFill" />
            </Grid.Background>
            <StackPanel Background="Black" Width="0" x:Name="PNL_Search" Grid.ZIndex="1" Grid.Column="1" HorizontalAlignment="Right">
                <StackPanel.Style>
                    <Style>
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding SearchActive}" Value="True">
                                <DataTrigger.EnterActions>
                                    <BeginStoryboard>
                                        <Storyboard>
                                            <StaticResource ResourceKey="ShowSearchAnimation" />
                                        </Storyboard>
                                    </BeginStoryboard>
                                </DataTrigger.EnterActions>
                                <DataTrigger.ExitActions>
                                    <BeginStoryboard>
                                        <Storyboard>
                                            <StaticResource ResourceKey="HideSearchAnimation" />
                                        </Storyboard>
                                    </BeginStoryboard>
                                </DataTrigger.ExitActions>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </StackPanel.Style>
            </StackPanel>
            <dxdo:DockLayoutManager DockItemDocking="DockLayoutManager_DockItemDocking" DockItemEndDocking="DockLayoutManager_DockItemDocking" DockItemStartDocking="DockLayoutManager_DockItemStartDocking" Grid.Column="0" Grid.ZIndex="0" Background="Transparent" Grid.ColumnSpan="2" ItemsSource="{Binding Documents.Children}" loki:Bind.Model="{Binding Documents.Children}">
                <dxdo:MVVMHelper.LayoutAdapter>
                    <loki:DocumentItemLayoutAdapter HostingGroupName="DocumentGroup" />
                </dxdo:MVVMHelper.LayoutAdapter>
                <dxdo:DockLayoutManager.AutoHideGroups>
                    <dxdo:AutoHideGroup DockType="Left">
                        <dxdo:LayoutPanel ShowCaption="False" Caption="Navigation" AllowClose="False" AllowDock="False" ItemWidth="200" ShowPinButton="False" ShowCloseButton="False" ShowControlBox="False" ShowMaximizeButton="False">
                            <dxn:NavBarControl ItemsSource="{Binding Navigation.Children}">
                                <dxn:NavBarControl.View>
                                    <dxn:NavigationPaneView IsExpanded="True" IsExpandButtonVisible="False" />
                                </dxn:NavBarControl.View>
                            </dxn:NavBarControl>
                        </dxdo:LayoutPanel>
                    </dxdo:AutoHideGroup>
                </dxdo:DockLayoutManager.AutoHideGroups>
                <dxdo:LayoutGroup>
                    <dxdo:DocumentGroup loki:Bind.Model="{Binding Documents}" Background="Transparent" Name="DocumentGroup" MDIStyle="Tabbed" CaptionLocation="Top" ClosePageButtonShowMode="InActiveTabPageHeader">
                        <dxdo:DocumentGroup.ItemStyle>
                            <Style TargetType="{x:Type dxdo:DocumentPanel}">
                                <Setter Property="loki:Bind.Model" Value="{Binding}" />
                                <Setter Property="Background" Value="Transparent" />
                                <Setter Property="BorderThickness" Value="10" />
                                <Setter Property="Padding" Value="5" />
                                <Setter Property="ShowBorder" Value="True" />
                                <Setter Property="BorderBrush" Value="#FF515151" />
                            </Style>
                        </dxdo:DocumentGroup.ItemStyle>
                    </dxdo:DocumentGroup>
                </dxdo:LayoutGroup>
            </dxdo:DockLayoutManager>
        </Grid>
    </dxb:BarManager>
</dx:DXWindow>